#!/usr/bin/env python
# -*- coding: utf-8 -*-
# title       :
# author      : jarry

import sys
import os
import logging
from SceneCheckTool.checkScript.CheckBase import CheckBase

try:
    import maya.cmds as cmds
    import pymel.core as pm
    import jarryLibs.mayakit.MayaUtils as mu
    reload(mu)
except:
    pass

logging.basicConfig()
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)


class CheckArnoldSShaderTransmitAovs(CheckBase):
    def __init__(self):
        super(CheckArnoldSShaderTransmitAovs, self).__init__()
        pass

    def check(self):
        error_list = []
        surface_shader_list = cmds.ls(type='aiStandardSurface')

        for ss in surface_shader_list:
            if cmds.getAttr('%s.transmission' % ss) > 0 and not cmds.getAttr('%s.transmitAovs' % ss):
                error_list.append(ss)

        if error_list:
            result_log = u'Error:%s\n' % error_list
        else:
            result_log = u'Succeed:没有问题\n'

        return result_log

    def fix(self):
        surface_shader_list = cmds.ls(type='aiStandardSurface')
        for ss in surface_shader_list:
            if cmds.getAttr('%s.transmission' % ss) > 0:
                cmds.setAttr('%s.transmitAovs' % ss, True)
        return self.check()



